<template>
  <div class="dynamic-block home-section bg-white">
    <div class="home-title">最新动态</div>
    <div class="content">
      <router-link
          v-if="list[0]"
          :to="{ name: 'NewsDetail', query: { id: list[0]?.id } }"
          target="_blank"
          class="item-1 item"
          :style="bgStyle(list[0].infoPicUrl)"
      >
        <div class="item-inner">
          <div class="item-title">{{ list[0].infoTitle }}</div>
          <div class="item-content">{{ list[0].infoSimpleDesc }}</div>
        </div>
      </router-link>
      <div class="content-right">
        <router-link
            v-if="list[1]"
            class="item-2 item"
            :to="{ name: 'NewsDetail', query: { id: list[1]?.id } }"
            target="_blank"
            :style="bgStyle(list[1].infoPicUrl)"
        >
          <div class="item-inner">
            <div class="item-title">{{ list[1].infoTitle }}</div>
          </div>
        </router-link>
        <div class="content-right-bottom">
          <router-link
              v-if="list[2]"
              class="item-3 item"
              :to="{ name: 'NewsDetail', query: { id: list[2]?.id } }"
              target="_blank"
              :style="bgStyle(list[2].infoPicUrl)"
          >
            <div class="item-inner">
              <div class="item-title">{{ list[2].infoTitle }}</div>
            </div>
          </router-link>
          <router-link
              v-if="list[3]"
              class="item-4 item"
              :to="{ name: 'NewsDetail', query: { id: list[3]?.id } }"
              target="_blank"
              :style="bgStyle(list[3].infoPicUrl)"
          >
            <div class="item-inner">
              <div class="item-title">{{ list[3].infoTitle }}</div>
            </div>
          </router-link>
        </div>
      </div>
    </div>
    <More path="news?type=5" />
  </div>
</template>

<script setup>
import { useNewsList } from "@/hooks";
import More from "./more.vue";

const { list } = useNewsList({ pageSize: 4, infoType: 5 });

const bgStyle = computed(() => {
  return (url) => ({
    background: `url(${url}) no-repeat center`,
  });
});
</script>

<style lang="less" scoped>
.dynamic-block {
  padding-bottom: 100px;
  .home-title {
    font-size: 24px;
    margin-bottom: 48px;
  }
}

.content {
  width: 95%;
  height: 468px;
  overflow: hidden;
  display: flex;
  margin-bottom: 32px;
  justify-content: space-between;
  &-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    &-bottom {
      flex: 1;
      display: flex;
      justify-content: space-between;
    }
  }
}

.item {
  position: relative;
  background-size: cover !important;
  cursor: pointer;
  overflow: hidden;
  &::after,
  &-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
  &::after {
    content: "";
    z-index: 1;
    top: 0;
    background: linear-gradient(180deg, rgba(0, 14, 50, 0) 0%, #000d2c 100%);
    transition: top 0.2s ease-out;
  }
  &-1 {
    width: 654px;
    height: 100%;
    margin-right: 11px;
  }
  &-2 {
    width: 100%;
    height: 258px;
    margin-bottom: 11px;
  }
  &-3 {
    width: 325px;
    height: 100%;
    margin-right: 11px;
  }
  &-4 {
    flex: 1;
    height: 100%;
  }
  &-inner {
    box-sizing: border-box;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: #fff;
    padding: 14px 16px;
  }
  &-title {
    font-size: 18px;
    font-weight: 500;
    width: 95%;
    .single-overflow;
  }
  &-content {
    font-size: 14px;
    opacity: 0.7;
    margin: 12px 0;
    .multiline-overflow(2);
  }
}

.item:hover {
  &::after {
    top: 100%;
  }
}

@media screen and (max-width: 1200px) {
  .content {
    flex-direction: column;
    height: auto;
    .item-1 {
      width: 100%;
      height: 300px;
      margin-right: 0;
      margin-bottom: 16px;
    }
    .content-right {
      flex-direction: row;
      .item-2 {
        width: 48%;
        height: 150px;
        margin-bottom: 0;
        margin-right: 4%;
      }
      .content-right-bottom {
        flex-direction: column;
        .item-3 {
          width: 100%;
          height: 150px;
          margin-right: 0;
          margin-bottom: 16px;
        }
        .item-4 {
          width: 100%;
          height: 150px;
        }
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .content {
    .item-1 {
      height: 200px;
    }
    .content-right {
      .item-2 {
        height: 100px;
      }
      .content-right-bottom {
        .item-3,
        .item-4 {
          height: 100px;
        }
      }
    }
  }
}
</style>
